package com.core.model.lxf;

import java.util.HashMap;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * User: lb
 * Date: 2016/3/1
 * Time: 13:49
 * To change this template use Editor | File and Code Templates.
 */
public class VoteManager {

    public static Map<String, String> voteMap = new HashMap<>();
    public static Map<String, Integer> voteCount = new HashMap<>();

    /**
     * 投票系统，根据用户投票次数实现不同子类
     *
     * @param user
     * @param voteContent
     */
    public void doVote(String user, String voteContent) {
        Integer integer = voteCount.get(user);
        Vote vote = null;
        if (integer == null) {
            integer = 0;
        }
        integer = integer + 1;
        voteCount.put(user, integer);
        if (integer <= 3) {
            vote = new NomelVoteImpl();
        } else if (integer > 3 && integer <= 5) {
            vote = new RepeatVote();
        } else if (integer > 5 && integer <= 8) {
            vote = new MaliceVote();
        } else if (integer > 8) {
            vote = new BackVote();
        }
        vote.doVote(user, voteContent, this);
    }

    public static void main(String[] areg) {
        VoteManager voteManager = new VoteManager();
        for (int i = 0; i < 10; i++) {
            voteManager.doVote("仙飞", "A");
        }
    }


}
